var mongoose = require('mongoose')
var db = mongoose.createConnection('localhost', 'example1_test2')

db.on('error', console.error.bind(console, '连接错误:'))
db.once('open', function(){
    var PersonSchema = new mongoose.Schema({
        name: String
    })
    PersonSchema.methods.speak = function(){
        console.log('我的名字叫' + this.name)
    }

    var PersonModel = db.model('Person', PersonSchema);
    var personEntity = new PersonModel({name: 'hahahah'})
    personEntity.speak()
})